package com.datang.pet.common.utils;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-05-12 18:35
 * @notify
 * @version 1.0
 */

import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class StringUtils {
    /*
     * @author 顶风少年
     * @date 2019/5/18 16:31
     * @mail dfsn199703132038@foxmail.com
     * @throws
     * @param
     * @result java.lang.String
     * @notify 生成UUID
     * version 1.0
     */
    public static String getId() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    /*
     * @author 顶风少年
     * @date 2019/5/18 16:34
     * @mail dfsn199703132038@foxmail.com
     * @throws
     * @param
     * @param str
     * @result boolean
     * @notify  true  不是空值可用  ，false  是空值没用
     * version 1.0
     */
    public static boolean isNUll(String str) {
        if (str == null) {
            return false;
        } else {
            //去掉空格
            str = str.replace(" ", "");
            return str != "";
        }

    }


    /* //https://petvideo.oss-cn-beijing.aliyuncs.com/ 2110165501bc57cb3fbb728626068333.mp4
     * @author 顶风少年
     * @date 2019/5/24 12:12
     * @mail 1204378372@qq.com
     * @throws
     * @param
     * @param sourceUrl
     * @result java.lang.String
     * @notify 获取资源的名字
     * version 1.0
     */
    public static String getSourceName(String sourceUrl){
        int index = sourceUrl.lastIndexOf("/");
        return sourceUrl.substring(index+1,sourceUrl.length());
    }

    /* //https://petvideo.oss-cn-beijing.aliyuncs.com/2110165501bc57cb3fbb728626068333  .mp4
     * @author 顶风少年
     * @date 2019/5/24 12:12
     * @mail 1204378372@qq.com
     * @throws
     * @param
     * @param sourceUrl
     * @result java.lang.String
     * @notify 获取资源的类型
     * version 1.0
     */
    public static String getSourceMimeType(String sourceUrl){
        int index = sourceUrl.lastIndexOf(".");
        return sourceUrl.substring(index,sourceUrl.length());
    }
}
